USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_SEGUROS]    Script Date: 11/24/2011 14:36:53 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0002_SEGUROS]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0002_SEGUROS]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_SEGUROS]    Script Date: 11/24/2011 14:36:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[WASP_M0002_SEGUROS] 
AS 
BEGIN 
	SELECT	cs.ppsuc
			,cs.ppcta
			,cs.ppoper
			,vs.ppimp11 AS cod_seg1
			,cs.ppimp11 AS val_seg1
			,vs.ppimp12 AS cod_seg2
			,cs.ppimp12 AS val_seg2
			,vs.ppimp13 AS cod_seg3
			,cs.ppimp13 AS val_seg3
			,vs.ppimp14 AS cod_seg4
			,cs.ppimp14 AS val_seg4
			,vs.ppimp15 AS cod_seg5
			,cs.ppimp15 AS val_seg5
			,vs.ppimp16 AS cod_seg6
			,cs.ppimp16 AS val_seg6
			,vs.ppimp17 AS cod_seg7
			,cs.ppimp17 AS val_seg7
			,vs.ppimp18 AS cod_seg8
			,cs.ppimp18 AS val_seg8
			,vs.ppimp19 AS cod_seg9
			,cs.ppimp19 AS val_seg9
	INTO	seguros
	FROM	valores_seguros AS cs,
			codigos_seguros AS vs
	WHERE	cs.ppsuc  = vs.ppsuc
	AND		cs.ppcta  = vs.ppcta 
	AND		cs.ppoper = vs.ppoper
	ORDER BY vs.ppimp11
END

GO


